|
|
|
|
|
|
|
Figure 29.1
INI file examples. |
|
|
|
|
|
|
|
|
The first API call youll use is GetPrivateProfileString(). This function retrieves a key value from a given section and key name. To use this function, you need to declare a buffer area to receive the value youre retrieving. Also, notice that you must assign the values of the text boxes to actual string variables, because you cannot pass the contents of a text box to a Windows API call. Heres an example using GetPrivateProfileString(): |
|
|
|
 |
|
|
|
|
Private Sub cmdGet_Click()
Dim lngRet As Long
Dim strIni As String
Dim strSection As String
Dim strKeyName As String
Dim strKeyValue As String
strIni = Trim$(txtConfig)
strSection = Trim$(txtSection)
strKeyName = Trim$(txtKeyName)
strKeyValue = Space(255) lngRet = GetPrivateProfileString( _
strSection, _
strKeyName, _
"", _
strKeyValue, _
Len(strKeyValue), _
strIni)
txtKeyValue = Left$(strKeyValue, lngRet)
End Sub |
|
|
|
|
|